package JDBC;

import java.sql.SQLException;

/**
 * 测试score_table数据库操作
 * @Author Alex
 */
@Deprecated
public class HandlerTest01 {
    public static void main(String[] args) {
        //插入分数数据,ok
//        Score ydl = new Score("吉祥",30);
//        try {
//        SQLHandler.insertScore(ydl);
//    } catch (SQLException throwables) {
//        throwables.printStackTrace();
//    } catch (ClassNotFoundException e) {
//        e.printStackTrace();
//    }

        //查询所有分数信息,ok
//        try {
//            List<Score> scoreList = SQLHandler.queryAllScore();
//            for (Score s:scoreList){
//                System.out.println(s.toString());
//            }
//        } catch (SQLException throwables) {
//            throwables.printStackTrace();
//        } catch (ClassNotFoundException e) {
//            e.printStackTrace();
//        }

        //查询单个分数信息,ok
//        Integer id = 8;
//        try {
//            Score score = SQLHandler.queryScore(id);
//            System.out.println(score.toString());
//        } catch (SQLException throwables) {
//            throwables.printStackTrace();
//        } catch (ClassNotFoundException e) {
//            e.printStackTrace();
//        }

        //降序排列后输出,ok
//        try {
//            List<Score> scoreList = SQLHandler.rankScore();
//            System.out.println(scoreList);
//        } catch (SQLException | ClassNotFoundException throwables) {
//            throwables.printStackTrace();
//        }

        //修改分数,从网页获取点击修改后传出来的Score对象,修改分数,,ok
        //此对象的id,name在原数据库中都存在,分数与原来不同,我们根据id修改分数
        Score s2 = new Score(2,"ljw",120);
        try {
            SQLHandler.updateScore(s2);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }


    }
}
